package com.serkol.driving.learning.api;

import com.serkol.annotation.IsLogin;
import com.serkol.bean.MyPage;
import com.serkol.bean.Result;
import com.serkol.constant.ResultConstant;
import com.serkol.driving.learning.service.LoginLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("api/oauth/system/log")
public class SystemLogApiController {
@Autowired
    private LoginLogService logService;
    @IsLogin
    @GetMapping("/login")
    public Result login(@RequestParam(name="pageSize", defaultValue = "10") int pageSize, @RequestParam(name="page", defaultValue = "0") int page){
        Result result = new Result();
        MyPage list = logService.findByList(pageSize, page);
        if (list.getSize()>0) {
            result.setStatus(ResultConstant.SUCSESS);
            result.setData(list);
        } else {
            result.setStatus(ResultConstant.EMPTIY);
        }
        return result;
    }
}
